﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BMSQ.Utility;

namespace BMSQ.Admin.Accounts.User
{
    public partial class ChangePwd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
            if (Common.UserInfo.User.UserPwd != txtOldPwd.Text)
            {
                strErr += "原密码错误！\\n";
            }
            if (this.txtNewPwd.Text.Trim().Length == 0)
            {
                strErr += "密码不能为空！\\n";
            }
            if (this.txtNewPwd.Text.Trim() != this.txtConfirmPwd.Text.Trim())
            {
                strErr += "两次输入的密码不一致！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            Vincent.Permission.Model.account_userlist model = Vincent.Permission.Functions.Account.GetSingleUser(Common.UserInfo.User.UserID); //bll.GetModel(Common.UserInfo.User.UserID);
            model.UserPwd = txtNewPwd.Text;

            Vincent.Permission.Functions.Account.UpdateUser(model);
            MessageBox.ShowAndRedirect(this, "修改成功！", "Show.aspx?UserID=" + model.UserID);
        }

        protected void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("Show.aspx?UserID=" + Common.UserInfo.User.UserID);
        }
    }
}